#!/bin/bash
set -uxe

MODULE="$1"
dir=`dirname $0`
cd $dir/${MODULE}
for dir in `ls`
do
    if [ -d $dir ]; then
        pushd $dir
        cp ../../ut_report/* .
        cp *.[ch] ../
        popd
    else
        continue
    fi
done

#新版本的lcov默认是把分支覆盖的统计关闭的，需要打开相关选项lcov_branch_coverage = 1
sed -i 's#lcov_branch_coverage = 0#lcov_branch_coverage = 1#g' /etc/lcovrc

lcov -d . -c -b . -o ut.info
lcov -r ut.info '*/cJSON.c' -o ut.info
rm -rf html; mkdir html
genhtml --no-prefix --no-sort ut.info -o ./html
gensummary ut.info ./html/ut.xml
mkdir -p /html
rm -rf /html/*
cp -r ./html/* /html/
